package generator.controller;

import com.atkt.ktkt.model.vod.Subject;
import generator.service.SubjectService;
import ktkt.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author KT917
 * @date 2022/9/18
 */

@Api(tags = "课程分类管理")
@RequestMapping(value="/admin/vod/subject")
//@CrossOrigin
@RestController
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    //课程分类列表
    @ApiOperation("课程分类列表")
    @GetMapping("/getChildSubject/{id}")
    public Result getChildSubject(@PathVariable Long id){
         List<Subject> list= subjectService.selectSubjectList(id);
         return  Result.ok(list);
    }

    //课程分类导出
    @ApiOperation("课程分类导出")
    @GetMapping("/exportData")
    public void exportData(HttpServletResponse response){
        subjectService.exportData(response);
    }

    //课程分类导入
    @ApiOperation("课程分类导入")
    @PostMapping("/importData")
    public Result importData(MultipartFile file){
        subjectService.importData(file);
        return Result.ok(null);
    }


}
